<?php

/**
 * Composer of source db version 2.0
 * To help declare source of Db name more efficient
 * @package ComposerSourceDbV2
 * @see Composer
 */
class ComposerSourceDbV2 extends ComposerSourceDb{

  /**
   * @var Database
   */
  private $Db;

  /**
   * init the Db driver
   *
   * @param Database $Db
   */
  function init($Db){

    $this->Db = $Db;
  }


  function setFieldAndType($value){

    $query  = "select * from ".$value." where ROWNUM=1";

    $this->Db->execFetchField($query, $result);

    var_dump($result);
  }

  /**
   * add the identifier
   *
   * @param string  $key
   * @param string  $value
   */
  function add($key, $value){

    $index = &$this->index;

    $this->key[$index]    = $key;

    $this->value[$index]  = $value;

    /**
     * set the field and type of this table
     * from database
     */
    $this->setFieldAndType($value);

    $index++;
  }

  /**
   * fetch the key by value
   *
   * @param string  $value
   * @return string
   */
  function fetchKey($value){

    $index = array_search($value, $this->value);

    return $this->key[$index];
  }

  /**
   * fetch value by key
   *
   * @param string  $key
   * @return string
   */
  function fetchValue($key){

    $index = array_search($key, $this->key);

    return $this->value[$index];
  }

  function del($key, $value){


  }


  function edit($key, $value){


  }
}

?>